package com.example.springbootdemo.web;

import com.example.springbootdemo.bean.User;
import com.yc.login.web.UserDo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
public class IndexAction {
    @RequestMapping("hello")
    public String hello(String name){
        return "你好 " + name;
    }

    @Value("张三")
    String name;
    @Value("${demo.age}")
    int age;

    @Value("${demo.my-name}")
    String myName;

//    @Resource
//    UserDo userDo;
//
//    @RequestMapping("testUser")
//    public UserDo userDo(){
//        return userDo;
//    }

    @GetMapping("myinfo")
    public Map<String,Object> myinfo(){
        Map<String,Object> info = new HashMap<>();
        info.put("name",name);
        info.put("age",age);
        info.put("myName",myName);
        return info;
    }

    @Resource
    User user;

    @GetMapping("getUser")
    public User getUser(){
        return user;
    }
}
